package com.cqhfan.core.domain;

import lombok.AllArgsConstructor;
import lombok.Data;

@AllArgsConstructor
@Data
public class Result<T> {

    private T data;

    private Integer code;

    private String msg;

    public static <T> Result<T> success(T data) {
        return new Result<>(data, 200, "success");
    }

    public static <T> Result<T> success(T data, String msg) {
        return new Result<>(data, 200, msg);
    }

    public static <T> Result<T> success() {
        return new Result<>(null, 200, "success");
    }

    public static <T> Result<T> fail(String msg) {
        return new Result<>(null, 500, msg);
    }

    public static <T> Result<T> unAuthorizationResult() {
        return new Result<>(null, 401, null);
    }

    public static <T> Result<T> forbiddenResult() {
        return new Result<>(null, 403, null);
    }

}
